//
//  YZPigGroupDocBaseInfoViewModel.m
//  VET
//
//  Created by YZ on 2018/7/21.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZPigGroupDocBaseInfoViewModel.h"
#import "YZPigGroupDocBaseInfoModel.h"
#import "NSDate+Category.h"

@implementation YZPigGroupDocBaseInfoViewModel

@synthesize dataSource = _dataSource;

- (instancetype)init
{
    if(self = [super init]){
        [self config];
    }
    return self;
}

- (void)config
{
}

- (void)setModel:(YZSwineryModel *)model
{
    _model = model;
    YZPigGroupDocBaseInfoModel *earModel = [YZPigGroupDocBaseInfoModel new];
    earModel.title = @"批次号";
    earModel.content = model.batchNo;
    
    YZPigGroupDocBaseInfoModel *typeModel = [YZPigGroupDocBaseInfoModel new];
    typeModel.title = @"分类";
    typeModel.content = model.herdClass.itemValue;
    
    YZPigGroupDocBaseInfoModel *createModel = [YZPigGroupDocBaseInfoModel new];
    createModel.title = @"创建日期";
    NSDate *dateCreated = [NSDate dateWithTimeIntervalSince1970:model.gmtCreated];
    createModel.content = [dateCreated localDateString];
    
    YZPigGroupDocBaseInfoModel *birthModel = [YZPigGroupDocBaseInfoModel new];
    birthModel.title = @"出生日期";
    NSDate *dateBorn = [NSDate dateWithTimeIntervalSince1970:model.herdBirthdate];
    birthModel.content = [dateBorn localDateString];
    
    YZPigGroupDocBaseInfoModel *dateModel = [YZPigGroupDocBaseInfoModel new];
    dateModel.title = @"日龄 (天)";
    dateModel.content = model.herdBirthdateStr;
    
    YZPigGroupDocBaseInfoModel *numModel = [YZPigGroupDocBaseInfoModel new];
    numModel.title = @"初始头数 (头)";
    numModel.content = [NSString stringWithFormat:@"%ld",model.initQty];
    
    YZPigGroupDocBaseInfoModel *currentModel = [YZPigGroupDocBaseInfoModel new];
    currentModel.title = @"实时存栏 (头)";
    currentModel.content = [NSString stringWithFormat:@"%ld",model.realQty];
    
    YZPigGroupDocBaseInfoModel *statusModel = [YZPigGroupDocBaseInfoModel new];
    statusModel.title = @"当前状态";
    statusModel.content = model.herdState.itemValue;
    
    _dataSource = @[@[earModel,typeModel,createModel,birthModel,dateModel,numModel,currentModel,statusModel]];
}
@end
